#include "threadsensordata.h"
#include "sensordataprocess.h"

ThreadSensorData::ThreadSensorData(QObject *parent) :
    QThread(parent)
{
}

void ThreadSensorData::run()
{
    sensorDataProcess=new SensorDataProcess();
    connect(this,SIGNAL(sigProcessSensorData(QByteArray,QHostAddress,quint16)),sensorDataProcess,
            SLOT(slotProcessSensorData(QByteArray,QHostAddress,quint16)));
    connect(sensorDataProcess,SIGNAL(sigEventNotify(QByteArray,QString,quint16)),
            this,SIGNAL(sigEventNotify(QByteArray,QString,quint16)));
    connect(sensorDataProcess,SIGNAL(sigInfo(QString)),
            this,SIGNAL(sigInfo(QString)));
    connect(sensorDataProcess,SIGNAL(sigError(QString)),this,SIGNAL(sigError(QString)));
    connect(sensorDataProcess,SIGNAL(sigPacketNodeToServer(QByteArray,QHostAddress,quint16,bool)),
            this,SIGNAL(sigPacketNodeToServer(QByteArray,QHostAddress,quint16,bool)));

    exec();
}

ThreadSensorData::~ThreadSensorData()
{
    sensorDataProcess->deleteLater();
    exit(0);
    wait(500);
}
